﻿
Namespace internalFunctions
#If Not PocketPC AndAlso Not Smartphone Then
    'parameters, i, any, convert to string
    'return, string, the xml encoded string
    Public Class encodingxml
        Inherits internalFunction

        Public Class parameters
            Public Const i As String = "i"
        End Class

        Private Shared m As iParametersMapping = Nothing

        Shared Sub New()
            initialMapping(m, parameters.i)
        End Sub

        Public Sub New()
            MyBase.New("encoding.xml", m)
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim i As String = Nothing
            If ctx.findVariableStr(parameters.i, i) Then
                output = New bare_variable(typeDefination.string, urlUtils.xmlizate(i))
                Return True
            Else
                raiseError("expect parameter " + parameters.i, errorHandle.errorType.user)
                Return False
            End If
        End Function
    End Class

    Public Class decodingxml
        Inherits inputIFunction(Of String, String)

        Public Sub New()
            MyBase.New("decoding.xml")
        End Sub

        Protected Overrides Function finder() As iVariableFinder(Of String)
            Return string_finder()
        End Function

        Protected Overrides Function invoke(ByVal i As String, ByRef o As String) As Boolean
            o = urlUtils.dexmlizate(i)
            Return True
        End Function

        Protected Overrides Function returnType() As typeDefination
            Return typeDefination.string
        End Function
    End Class
#End If

    Public Class encodingurl
        Inherits inputIFunction(Of String, String)

        Public Sub New()
            MyBase.New("encoding.url")
        End Sub

        Protected Overrides Function finder() As iVariableFinder(Of String)
            Return string_finder()
        End Function

        Protected Overrides Function invoke(ByVal i As String, ByRef o As String) As Boolean
            o = urlUtils.urlencode(i)
            Return True
        End Function

        Protected Overrides Function returnType() As typeDefination
            Return typeDefination.string
        End Function
    End Class

    Public Class decodingurl
        Inherits inputIFunction(Of String, String)

        Public Sub New()
            MyBase.new("decoding.url")
        End Sub

        Protected Overrides Function finder() As iVariableFinder(Of String)
            Return string_finder()
        End Function

        Protected Overrides Function invoke(ByVal i As String, ByRef o As String) As Boolean
            o = urlUtils.urldecode(i)
            Return True
        End Function

        Protected Overrides Function returnType() As typeDefination
            Return typeDefination.string
        End Function
    End Class
End Namespace